/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package queenb.web.controller;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.faces.model.SelectItem;
import queenb.net.entitybean.A000;
import queenb.net.entitybean.V150;
import queenb.web.crm.controller.V030controller;
import queenb.web.store.A000Store;
import queenb.web.store.V150Store;
import queenb.web.util.ComboboxUtil;
import queenb.web.util.ContextUtil;
import queenb.web.util.SessionProvider;
import queenb.web.util.Util;

/**
 *
 * @author Nguyen Hung
 */
public class V150Controller extends QueenbController {
    private int pv150;
    private String vv151;// -- hang khong ddi
   private String vv152;//-- VV152` varchar(32),  -- so chuyen bay
   private String vv153;//-- VN153` varchar(64),  -- ddiem khoi hanh
   private String vv154;//-- VN154` varchar(64),  -- ddiem dden
   private Date vd155;//-- VD155` date,         -- ngay ddi
   private int vn156;//-- VN156` int,          -- gio ddi
   private int vn157;//-- VN157` int,          -- phut ddi
   private Date vd158;//-- VD158` date,         -- ngay dden
   private int vn159;//-- VN159` int,          -- gio dden
   private int vn160;//-- VN160` int,          -- phut dden
   private String vv161;//-- VV161` varchar(32), -- hang khong ve
   private String vv162;//-- VV162` varchar(32),  -- so chuyen bay
   private String  vn163;//-- VN163` varchar(64),  -- ddiem khoi hanh
   private String vn164;// VN164` varchar(64),  -- ddiem dden
   private Date vd165;//-- VD165` date,         -- ngay ddi
   private int vn166;//-- VN166` int,          -- gio ddi
   private int vn167;//-- VN167` int,          -- phut ddi
   private Date vd168;//-- VD168` date,         -- ngay dden
   private int vn169;//-- VN169` int,          -- gio dden
   private int vn170;//-- VN170` int,          -- phut dden
   private int fv050;//-- FV050` int(11) NOT NULL,
   private int fk100f;//-- FK100F` int,         -- nha cung cap ddi -- tam chua su dung
   private int fk100t;//-- FK100T` int,         -- nha cung cao ve
    private List<SelectItem> combolistN750 = new ArrayList<SelectItem>();
    private ComboboxUtil comboboxUtil;
    private V150Store v150Store;
    private List<V150> listoftabV150 = new ArrayList<V150>();

    public V150Controller() {
        v150Store = new V150Store();
       // v150Store.vcurpks_listoftabv150(pv150, vv151)
        comboboxUtil = new ComboboxUtil();
        Object action = getRequest().getParameter("action");
        if(action != null)
        {
           if(action.equals("addpersonalforTour")){
                Object Ofv050 = getRequest().getParameter("pv050");
                if(Ofv050!=null){
                    fv050 = Util.parseInt(Ofv050);
                }
            }else if(action.equals("deleteV150")){
                Object Ofv050 = getRequest().getParameter("pv150");
                if(Ofv050!=null){
                    pv150 = Util.parseInt(Ofv050);
                    SessionProvider.setSessionMapValue("IDELETEV150", pv150);
                       System.out.println("-----ID FV150-----"+SessionProvider.getSessionMapValue("IDELETEV150"));
                }
                
            }
           
           System.out.println("--------FV050---"+fv050);
        }
    }
    
    // delete V150
    public void stdv_tools_stornotabv150(){
        try {
            int count = v150Store.stdv_tools_stornotabv150(Util.parseInt(SessionProvider.getSessionMapValue("IDELETEV150")), getLogin().getUserName());
             System.out.println("------COUNT DLETE V150--"+count);
        } catch (Exception e) {
        }
    }

    public void stdv_tools_inserttabv150() {
    //    System.out.println("--------------" + pa000+av001+av002+av003+fn750);
        try {
            String date = ContextUtil.getRequestParameter("leavedate1");
            if (!date.equals("")) {
                setVd155(Util.parseDate(date, "dd/MM/yyyy"));
            } else {
                setVd155(null);
            }

            date = ContextUtil.getRequestParameter("leavedate2");
            if (!date.equals("")) {
                setVd158(Util.parseDate(date, "dd/MM/yyyy"));
            } else {
                setVd158(null);
            }
             date = ContextUtil.getRequestParameter("leavedate3");
            if (!date.equals("")) {
                setVd165(Util.parseDate(date, "dd/MM/yyyy"));
            } else {
                setVd165(null);
            }

            date = ContextUtil.getRequestParameter("leavedate4");
            if (!date.equals("")) {
                setVd168(Util.parseDate(date, "dd/MM/yyyy"));
            } else {
                setVd168(null);
            }
            System.out.println("------THAM SO KHI TOUR-----"+getPv150()+","+ getVv151()+","+ getVv152()+","+getVv153()+","+ getVv154()+","+ Util.toSQLDate(getVd155())+","+ getVn156()+","+ getVn157()+","+ Util.toSQLDate(getVd158())+","+ getVn159()+","+ getVn160()+","+ getVv161()+","+ getVv162()+","+ getVn163()+","+ getVn164()+","+ Util.toSQLDate(getVd165())+","+ getVn166()+","+ getVn167()+","+ Util.toSQLDate(getVd168())+","+ getVn169()+","+ getVn170()+","+ getFv050()+","+ getFk100f()+","+ getFk100t()+","+ getLogin().getUserName());
            int count = v150Store.stdv_tools_inserttabv150( getPv150(), getVv151(), getVv152(),getVv153(), getVv154(), Util.toSQLDate(getVd155()), getVn156(), getVn157(), Util.toSQLDate(getVd158()), getVn159(), getVn160(), getVv161(), getVv162(), getVn163(), getVn164(), Util.toSQLDate(getVd165()), getVn166(), getVn167(), Util.toSQLDate(getVd168()), getVn169(), getVn170(), getFv050(), getFk100f(), getFk100t(), getLogin().getUserName());
            System.out.println("--------COUNT---"+count);
            if (count != 0) {            
                sendRedirectUrlTab("customer4tour.jsp?status=T&pv050=" + fv050);
                showGlobalReport(true, getResourceString("datasavesuccessful"));
            } else {
                sendRedirectUrlTab("customer4tour.jsp?status=T&pv050=" + fv050);

                showGlobalReport(true, getResourceString("datasuccessfail"));
            }
        } catch (Exception e) {
        }
    }

    /**
     * @return the pv150
     */
    public int getPv150() {
        return pv150;
    }

    /**
     * @param pv150 the pv150 to set
     */
    public void setPv150(int pv150) {
        this.pv150 = pv150;
    }

    /**
     * @return the vv151
     */
    public String getVv151() {
        return vv151;
    }

    /**
     * @param vv151 the vv151 to set
     */
    public void setVv151(String vv151) {
        this.vv151 = vv151;
    }

    /**
     * @return the vv152
     */
    public String getVv152() {
        return vv152;
    }

    /**
     * @param vv152 the vv152 to set
     */
    public void setVv152(String vv152) {
        this.vv152 = vv152;
    }

    /**
     * @return the vv153
     */
    public String getVv153() {
        return vv153;
    }

    /**
     * @param vv153 the vv153 to set
     */
    public void setVv153(String vv153) {
        this.vv153 = vv153;
    }

    /**
     * @return the vv154
     */
    public String getVv154() {
        return vv154;
    }

    /**
     * @param vv154 the vv154 to set
     */
    public void setVv154(String vv154) {
        this.vv154 = vv154;
    }

    /**
     * @return the vd155
     */
    public Date getVd155() {
        return vd155;
    }

    /**
     * @param vd155 the vd155 to set
     */
    public void setVd155(Date vd155) {
        this.vd155 = vd155;
    }

    /**
     * @return the vn156
     */
    public int getVn156() {
        return vn156;
    }

    /**
     * @param vn156 the vn156 to set
     */
    public void setVn156(int vn156) {
        this.vn156 = vn156;
    }

    /**
     * @return the vn157
     */
    public int getVn157() {
        return vn157;
    }

    /**
     * @param vn157 the vn157 to set
     */
    public void setVn157(int vn157) {
        this.vn157 = vn157;
    }

    /**
     * @return the vd158
     */
    public Date getVd158() {
        return vd158;
    }

    /**
     * @param vd158 the vd158 to set
     */
    public void setVd158(Date vd158) {
        this.vd158 = vd158;
    }

    /**
     * @return the vn159
     */
    public int getVn159() {
        return vn159;
    }

    /**
     * @param vn159 the vn159 to set
     */
    public void setVn159(int vn159) {
        this.vn159 = vn159;
    }

    /**
     * @return the vn160
     */
    public int getVn160() {
        return vn160;
    }

    /**
     * @param vn160 the vn160 to set
     */
    public void setVn160(int vn160) {
        this.vn160 = vn160;
    }

    /**
     * @return the vv161
     */
    public String getVv161() {
        return vv161;
    }

    /**
     * @param vv161 the vv161 to set
     */
    public void setVv161(String vv161) {
        this.vv161 = vv161;
    }

    /**
     * @return the vv162
     */
    public String getVv162() {
        return vv162;
    }

    /**
     * @param vv162 the vv162 to set
     */
    public void setVv162(String vv162) {
        this.vv162 = vv162;
    }

    /**
     * @return the vn163
     */
    public String getVn163() {
        return vn163;
    }

    /**
     * @param vn163 the vn163 to set
     */
    public void setVn163(String vn163) {
        this.vn163 = vn163;
    }

    /**
     * @return the vn164
     */
    public String getVn164() {
        return vn164;
    }

    /**
     * @param vn164 the vn164 to set
     */
    public void setVn164(String vn164) {
        this.vn164 = vn164;
    }

    /**
     * @return the vd165
     */
    public Date getVd165() {
        return vd165;
    }

    /**
     * @param vd165 the vd165 to set
     */
    public void setVd165(Date vd165) {
        this.vd165 = vd165;
    }

    /**
     * @return the vn166
     */
    public int getVn166() {
        return vn166;
    }

    /**
     * @param vn166 the vn166 to set
     */
    public void setVn166(int vn166) {
        this.vn166 = vn166;
    }

    /**
     * @return the vn167
     */
    public int getVn167() {
        return vn167;
    }

    /**
     * @param vn167 the vn167 to set
     */
    public void setVn167(int vn167) {
        this.vn167 = vn167;
    }

    /**
     * @return the vd168
     */
    public Date getVd168() {
        return vd168;
    }

    /**
     * @param vd168 the vd168 to set
     */
    public void setVd168(Date vd168) {
        this.vd168 = vd168;
    }

    /**
     * @return the vn169
     */
    public int getVn169() {
        return vn169;
    }

    /**
     * @param vn169 the vn169 to set
     */
    public void setVn169(int vn169) {
        this.vn169 = vn169;
    }

    /**
     * @return the vn170
     */
    public int getVn170() {
        return vn170;
    }

    /**
     * @param vn170 the vn170 to set
     */
    public void setVn170(int vn170) {
        this.vn170 = vn170;
    }

    /**
     * @return the fv050
     */
    public int getFv050() {
        return fv050;
    }

    /**
     * @param fv050 the fv050 to set
     */
    public void setFv050(int fv050) {
        this.fv050 = fv050;
    }

    /**
     * @return the fk100f
     */
    public int getFk100f() {
        return fk100f;
    }

    /**
     * @param fk100f the fk100f to set
     */
    public void setFk100f(int fk100f) {
        this.fk100f = fk100f;
    }

    /**
     * @return the fk100t
     */
    public int getFk100t() {
        return fk100t;
    }

    /**
     * @param fk100t the fk100t to set
     */
    public void setFk100t(int fk100t) {
        this.fk100t = fk100t;
    }

    /**
     * @return the listoftabV150
     */
    public List<V150> getListoftabV150() {
        try {
            V030controller v030COntroller = new V030controller();
            if(v030COntroller.getFV050()!=0){
                fv050 = v030COntroller.getFV050();
            }
            listoftabV150 = v150Store.vcurpks_listoftabv150(fv050,getLogin().getUserName());
            System.out.println("--------LIST--"+listoftabV150.size());
            return listoftabV150;
        } catch (Exception e) {
            return null;
        }
        
    }

    /**
     * @param listoftabV150 the listoftabV150 to set
     */
    public void setListoftabV150(List<V150> listoftabV150) {
        this.listoftabV150 = listoftabV150;
    }
   
}
